# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
pkgname=clpeak
pkgver=1.1.2
pkgrel=1
pkgdesc="A tool which profiles OpenCL devices to find their peak capacities"
arch=('loong64' 'x86_64')
url="https://github.com/krrishnarraj/clpeak"
license=(custom:unlicense)
depends=('ocl-icd' 'gcc-libs')
makedepends=('cmake' 'opencl-headers' 'ninja' 'git')
source=(git+https://github.com/krrishnarraj/clpeak#tag=$pkgver
        git+https://github.com/krrishnarraj/libopencl-stub)
sha512sums=('SKIP'
            'SKIP')

prepare() {
  cd "$pkgname"

  git submodule init
  git config submodule."libopencl-stub".url "${srcdir}/libopencl-stub"
  git submodule update
}

build() {
    cd "$pkgname"
    cmake \
        -Bbuild \
        -GNinja \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr
    ninja -C build
}

package() {
    cd "$pkgname"

    install -Dm644 README.md "$pkgdir/usr/share/$pkgname/README.md"
    cp -r results "$pkgdir"/usr/share/$pkgname/results
    DESTDIR="$pkgdir" ninja -C build install
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
